home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STVWPRT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.2 KB  |  37 lines

  1. #include <graphics.h>
  2.  
  3. main()
  4. {
  5.    int graphdriver = DETECT, graphmode;
  6.  
  7.  /* Detect and initialize graphics system */
  8.    initgraph(&graphdriver, &graphmode, "c:\\turboc");
  9.    outtextxy(10,10, "Demonstration of setviewport with 2 viewports");
  10.  /* Set current color to red */
  11.    setcolor(RED);
  12.  /* Dashed lines for boundaries */
  13.    setlinestyle(USERBIT_LINE, 0xf0f, NORM_WIDTH);
  14.  /* Set a 200 x 200 viewport */
  15.    setviewport(0,100, 200, 300, 1);
  16.  /* Show boundary of viewport */
  17.    rectangle(0,0,200,200);
  18.  /* Now draw a pieslice, remember the coordinates of
  19.   * the center are specified in viewport coordinates
  20.   * with the origin at upper left corner of viewport.
  21.   */
  22.    setfillstyle(SOLID_FILL, YELLOW);
  23.    pieslice(150, 150, 0, 360, 100);
  24.  /* Now set another viewport, and redraw same slice */
  25.  /* This is a 150 x 150 viewport                    */
  26.    setviewport(240,100,390,250,1);
  27.  /* Again show boundary of the viewport */
  28.    rectangle(0,0,150,150);
  29.    setfillstyle(SLASH_FILL, YELLOW);
  30.  /* Draw the same ellipse again. */
  31.    pieslice(150, 150, 0, 360, 100);
  32.  
  33.  /* Exit graphics mode when user strikes any key */
  34.    outtextxy(10, getmaxy() - 50, "Press any key to exit");
  35.    getch();  /* A do-nothing read */
  36.    closegraph();
  37. }